package com.example.fms.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.fms.dto.req.ActivityReq;
import com.example.fms.dto.req.MinOrderRuleReqDto;
import com.example.fms.dto.resp.ActivityResp;
import com.example.fms.dto.resp.MinOrderRuleRespDto;
import com.example.fms.service.ActivityService;
import com.example.fms.service.ArithmeticLogInfoService;
import com.example.fms.vo.ResponseBean;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Validated
@RestController
@RequestMapping("/activity")
public class ActivityController {

    @Resource
    ActivityService activityService;
    /**
     * 活动查询
     * @param req 查询条件
     * @return 查询结果
     */
    @PostMapping("/list")
    public ResponseBean<Page<ActivityResp>> getActivityList(@RequestBody ActivityReq req) {
        return ResponseBean.success(activityService.getActivityList(req));
    }


    /**
     * 活动查询
     * @param
     * @return 查询结果
     */
    @GetMapping("/{id}")
    public ResponseBean<ActivityResp> getActivityList(@PathVariable Long id) {
        return ResponseBean.success(activityService.getActivityById(id));
    }


    /**
     * 发布
     * @param req 发布
     * @return 结果
     */
    @PostMapping("/release")
    public ResponseBean<Boolean> release(@RequestBody ActivityReq req) {
        return ResponseBean.success(activityService.release(req));
    }

    /**
     * 新建活动
     */
    @PostMapping("/save")
    public ResponseBean<Boolean> save(@RequestBody ActivityReq req) {
        return ResponseBean.success(activityService.insert(req));
    }

    /**
     * 删除
     * @param
     * @return
     */
    @DeleteMapping("/{id}")
    public ResponseBean<Boolean> delete(@PathVariable Long id) {
        return ResponseBean.success(activityService.delete(id));
    }


    /**
     * 修改
     * @param req
     * @return
     */
    @PostMapping("/update")
    public ResponseBean<Boolean> update(@RequestBody ActivityReq req) {
        return ResponseBean.success(activityService.updateActivity(req));
    }


}
